<template>
  <el-dialog title="网关编辑" width="800px" v-model="dialogFormVisible">
    <el-form :model="form" size="small">
      <el-form-item label="网关名称" :label-width="formLabelWidth">
        <el-input v-model="form.gateway_name" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="所属区域" :label-width="formLabelWidth">
        <el-select v-model="form.area_id" placeholder="请选区域">
          <el-option label="龙湖区域" :value="1"></el-option>
          <el-option label="罗湖区域" :value="2"></el-option>
          <el-option label="福田区域" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="网关类型" :label-width="formLabelWidth">
        <el-select v-model="form.gateway_type" placeholder="请选网关类型">
          <el-option label="网关类型AA" :value="1"></el-option>
          <el-option label="网关类型BB" :value="2"></el-option>
          <el-option label="网关类型CCC" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="灯杆类型" :label-width="formLabelWidth">
        <el-select v-model="form.category_id" placeholder="请选灯杆类型">
          <el-option label="灯杆类型AAA" :value="1"></el-option>
          <el-option label="灯杆类型BBB" :value="2"></el-option>
          <el-option label="灯杆类型CCC" :value="3"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="地址" :label-width="formLabelWidth">
        <el-input v-model="form.gateway_address" autocomplete="off"></el-input>
      </el-form-item>
      <el-form-item label="经纬度" :label-width="formLabelWidth">
        <el-input v-model="form.gateway_location" autocomplete="off"></el-input>
        <div class="pt10">
          <Getlnglat @getinglat="getinglatFunc"></Getlnglat>
        </div>
      </el-form-item>
      <el-form-item label="描述" :label-width="formLabelWidth">
        <el-input
          type="textarea"
          v-model="form.gateway_describe"
          autocomplete="off"
        ></el-input>
      </el-form-item>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button size="small" @click="cancelFunc()">取 消</el-button>
        <el-button size="small" type="primary" @click="confirmFunc()"
          >确 定</el-button
        >
      </span>
    </template>
  </el-dialog>
</template>

<script>
import Getlnglat from "@/components/map/Getlnglat.vue";
export default {
  components: {
    Getlnglat,
  },
  data() {
    return {
      //是否显示
      dialogFormVisible: false,
      //表单数据
      form: {
        //网关名称
        gateway_name: "",
        //所属区域
        area_id: 1,
        //网关类型
        gateway_type: 1,
        //灯杆类型
        category_id: 1,
        //经纬度
        gateway_location: "",
        //地址
        gateway_address: "",
        //描述
        gateway_describe: "",
      },
      //左边标签宽度
      formLabelWidth: "120px",
    };
  },
  props: {
    visible: Boolean,
  },
  watch: {
    //监听是否显示
    visible(newVal, oldVal) {
      if (newVal != oldVal) {
        this.dialogFormVisible = newVal;
      }
    },
  },
  created() {},
  mounted() {},
  methods: {
    /**
     * 获取经纬度
     */
    getinglatFunc(e) {
      this.form.gateway_location = e;
    },

    /**
     * 确认
     */
    confirmFunc() {
      this.$message({
        type: "success",
        message: "操作成功!",
      });
      this.cancelFunc();
    },

    /**
     * 取消
     */
    cancelFunc() {
      this.$emit("close", false);
    },
  },
};
</script>

<style lang="scss">
</style>
